﻿using MiniBottles.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MiniBottles.Controllers
{
  
    public class GuestBookController : Controller
    {

        private DataContext db = new DataContext();
        //
        // GET: /GuestBook/

        public ActionResult Index()
        {
            var result = db.GuestBooks.Where(x => !x.IsDeleted);
            return View(result);
        }
       
        public ActionResult Create()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Create(GuestBook guestBook)
        {
            GuestBook newWrit = new GuestBook();
            newWrit.Nick = guestBook.Nick;
            newWrit.WWW = guestBook.WWW;
            newWrit.Content = guestBook.Content;
            newWrit.Email = guestBook.Email;

            db.GuestBooks.Add(newWrit);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
    }
}
